home *** CD-ROM | disk | FTP | other *** search
- Path: engnews2.Eng.Sun.COM!taumet!clamage
- From: krotoff@such.srcc.msu.su (Alexander Krotoff)
- Newsgroups: comp.std.c++
- Subject: Appendix C (Compatibility)
- Date: 29 Jan 1996 19:15:24 GMT
- Organization: Research Computer Center, Moscow State University
- Sender: krotoff@boy.nmd.msu.ru
- Approved: clamage@eng.sun.com (comp.std.c++)
- Message-ID: <4eiih2$63u@boy.nmd.msu.ru>
- NNTP-Posting-Host: taumet.eng.sun.com
- Content-Type: text
- Content-Length: 2472
- X-Lines: 114
- Originator: clamage@taumet
-
- Hello c++ gurus,
-
- I have some remarks on the Appendix C (Compatibility).
-
- ------------------------------------------------------------------------
- C.1.1 C++ features available in 1985
-
- 13A pointer to function can be assigned to a void*; _conv.ptr_.
-
- Is it correct ?
-
- 4.10 Pointer conversions says:
- 2 An rvalue of type "pointer to cv T," where T is an object
- type, can be converted to an rvalue of type "pointer to
- cv void."
-
- The function type is not object type.
- ------------------------------------------------------------------------
- C.1.2 C++ features added since 1985
-
- Did you forgot namespaces in this list ?
-
- ========================================================================
- Additional differences ISO C/C++:
- ------------------------------------------------------------------------
- In C conversion to pointer types and null pointer constant may be used
- in the constant expression.
- In C++ they cannot be used in the context of integral constant expression.
-
- ANSI C 3.4
- WP C++ expr.const
-
- Example:
-
- #include <stddef.h>
-
- struct A {
- int a;
- int b;
- };
-
- void f()
- {
- int i;
-
- switch (i) {
- case 1:
- case offsetof (struct A, b):
- i--;
- }
- }
-
- Here I assume semi-standard definition of offsetof macro.
-
- ------------------------------------------------------------------------
- In C struct member can have the same name, as struct itself.
- In C++ it do not.
-
- Example:
-
- struct a { // vadid C
- int a; // invalid C++
- };
- ------------------------------------------------------------------------
- According to Extensions to ANSI C A.6.5.4 C compiler may use additional
- scope rules for external objects.
- There is no such rule in C++.
-
- Of course, this rule is not in the ANSI C itself.
-
- Example1:
-
- void f(void)
- {
- extern int a[];
- }
-
- void g()
- {
- int *pi = a+1; // Valid C, invalid c++.
- }
-
- Example2:
-
- void f(void)
- {
- extern void g(void);
- }
-
- void h(void)
- {
- void (*p)(void) = g;
- }
-
- ------------------------------------------------------------------------
- In C and C++ syntax for empty enum is differnent.
- In C enumerator list enclosed in `{}' is not allowed to be empty.
- In C++ empty enumerator list is allowed, but '{}'
- must be present.
-
- C++ WP dcl.enum
- ANSI C 3.5.2.2
-
- Example:
-
- enum a; // valid C, invalid C++.
- enum {}; // valid C++, invalid C.
- ------------------------------------------------------------------------
-
- --
- Alexander N. Krotoff krotoff@such.srcc.msu.su
- Research Computer Center tel: +7(095)939-2638
- Moscow State University fax: +7(095)939-4430
- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
- Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
- is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
-
-